
# A3d_plot_full_adj
#==============================================================================

# Description: This code creates the plot for the full model

rm(list = ls())

library('data.table')
library('stargazer')
library('ggplot2')


diff_data <- fread("results/price_index/diff_full_adj_actual.csv")

income_data <- fread(file = "Income.csv")

Reg_P_summary <- lm(diff ~ 0 + as.factor(declarant), data = diff_data)
print(summary(Reg_P_summary))

# Format Data to Save Regression Output

declarant <- unique(diff_data$declarant)
declarant <- sort(declarant)

income_data <- fread(file = "Income.csv")

# Save Regression

output <- merge(income_data, data.table(declarant, Reg_P_summary$coefficients), by = "declarant")
colnames(output) <- c(colnames(output)[1:4], "FE_declarant")
write.csv(file = "results/price_index/diff_Price_Index_full_adj_actual.csv", output)



